/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : SystemConfigTask.h
  * @brief          : System Config Task
  ******************************************************************************
  * @attention
  * 本文件用于  所有存储参数的处理
  * @20210329:文件模板第一次生成
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SYSTEM_CONFIG_TASK_H
#define __SYSTEM_CONFIG_TASK_H

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

#include "allconfig.h"

#include "SysFlash.h"

#include "SystemTimeListTask.h"

#include "SystemModbusTask.h"
#include "SysMasterTask.h"
/* USER CODE END Includes */

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

#define ADDR_START 			  0x08000000 //起始地址
#define ADDR_SECTOR_SIZE	2048       //每个扇区的大小

#define CONFIG_PRIORITY      9
#define CONFIG_STACK_SIZE    512
#define CONFIG_TIMESLICE     5

#define MODE_MQCP 0
#define MODE_MODBUS 1

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/

/* USER CODE BEGIN ET */

typedef struct
{
	uint16_t	Id;
	int16_t		Time_zone;
	uint16_t	mode;	//0:MQCP 1:MODBUS
  
  uint16_t	VerH;
	uint16_t	VerL;
  
}SysDataDef;

typedef struct
{//PowDataSaveDef
	
	uint16_t	BeginFlag;
	
	uint16_t	Buf[10];
	
	uint16_t  EndFlag;
	
}PowDataSaveDef;

typedef struct
{//SetDataSaveDef
	uint16_t				BeginFlag;
	
	MasterMainDef MasterSetConfig[DataSize];
	
	uint16_t				EndFlag;
	
}SetDataSaveDef;

typedef struct
{//TimDataSaveDef
	
	uint16_t	BeginFlag;
	
	sTimeListWorkDef sTimeListWork;
	
	uint16_t  EndFlag;
	
}TimDataSaveDef;

typedef struct
{//SysDataSaveDef
	
	uint16_t		BeginFlag;
	
	SysDataDef SysData;
	
	uint16_t  	EndFlag;
	
}SysDataSaveDef;

typedef struct
{//NetDataSaveDef
	
	uint16_t		BeginFlag;
	
	uint16_t		Buf[E_MBUS_WRREG_SIZE_NET];
	
	uint16_t  	EndFlag;
	
}NetDataSaveDef;

typedef struct
{//CalDataSaveDef
	uint16_t		BeginFlag;
	
  uint8_t		Buf[10];
	
	uint16_t  	EndFlag;
	
}CalDataSaveDef;

typedef struct
{
	uint8_t		*Buff;
	uint16_t 	Size;
	uint32_t 	Addr;
}SaveMailDef;

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */



/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */



/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
/* USER CODE BEGIN EFP */

extern void ConfigThreadCreate(void);

//extern void PowDataSave(uint16_t addr, uint8_t *buf, uint16_t size);
extern void SetDataSave(uint16_t addr, uint8_t *buf, uint16_t size);
extern void TimDataSave(uint16_t addr, uint8_t *buf, uint16_t size);
extern void SysDataSave(uint16_t addr, uint8_t *buf, uint16_t size);
extern void NetDataSave(uint16_t addr, uint8_t *buf, uint16_t size);
extern void CalDataSave(uint16_t addr, uint8_t *buf, uint16_t size);

extern void MqcpSetSave(uint16_t addr, uint8_t *buf, uint16_t size);
extern void MqcpTimSave(sTimeListDef *sTimeListWork, uint16_t Id, uint16_t state);
/* USER CODE END EFP */

#endif /* _CONFIG_TASK_H */

/************************ (C) COPYRIGHT CunJu *****END OF FILE****/
